package com.example.administrator.zkdemo.activity;

/**
 * Created with Android Studio.
 * 描述: ${DESCRIPTION}
 * Date: 2018/11/20
 * Time: 16:29
 *
 * @author 晏琦云
 * @version ${VERSION}
 */

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.administrator.zkdemo.adapter.ZKSettingAdapter;
import com.example.administrator.zkdemo.db.orm.manager.DataManager;
import com.example.administrator.zkdemo.model.ZKSettingBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class ZKSettingActivity extends ZKBaseActivity {
    public static final String CLOUD_CURSERVERTYPE = "CurServerType";
    private DataManager dataManager;
    private ZKSettingAdapter mAdapter;
    private int mCurServerType;
    private List<ZKSettingBean> mData = new ArrayList();

    @BindView(2131296508)
    RecyclerView mRvContent;

    @BindView(2131296585)
    TextView title;

    public static void actionStart(Context paramContext) {
        paramContext.startActivity(new Intent(paramContext, ZKSettingActivity.class));
    }

    private void initData() {
        this.dataManager = new DataManager();
        this.dataManager.open(getApplicationContext());
        this.mCurServerType = this.dataManager.getIntOption("CurServerType", 0);
        if (this.mCurServerType == 2) {
            // 系统设置
            this.mData.add(new ZKSettingBean(R.mipmap.blue_background, R.string.zk_ch_title_system_manage, R.mipmap.system_manage_icon));
            // 通讯设置
            this.mData.add(new ZKSettingBean(R.mipmap.light_blue_background, R.string.zk_ch_title_push_manage, R.mipmap.push_manage_icon));
            // 数据管理
            this.mData.add(new ZKSettingBean(R.mipmap.dark_yello_background, R.string.zk_ch_title_data_manage, R.mipmap.data_manage_icon));
            // U盘管理
            this.mData.add(new ZKSettingBean(R.mipmap.orange_background, R.string.zk_ch_title_UDisk_Manage, R.mipmap.udik_icon));
            // 广告设置
            this.mData.add(new ZKSettingBean(R.mipmap.dl_bg_0012, R.string.zk_setting_ad_title, R.mipmap.dl_ad_0002));
            // 系统信息
            this.mData.add(new ZKSettingBean(R.mipmap.pink_background, R.string.zk_ch_title_Equipment_Information, R.mipmap.devices_manage_icon));
            return;
        }
        // 员工管理
        this.mData.add(new ZKSettingBean(R.mipmap.green_background, R.string.zk_ch_title_user_manage, R.mipmap.user_manage_icon));
        // 通讯设置
        this.mData.add(new ZKSettingBean(R.mipmap.light_blue_background, R.string.zk_ch_title_push_manage, R.mipmap.push_manage_icon));
        // 系统设置
        this.mData.add(new ZKSettingBean(R.mipmap.blue_background, R.string.zk_ch_title_system_manage, R.mipmap.system_manage_icon));
        // 数据管理
        this.mData.add(new ZKSettingBean(R.mipmap.dark_yello_background, R.string.zk_ch_title_data_manage, R.mipmap.data_manage_icon));
        // U盘管理
        this.mData.add(new ZKSettingBean(R.mipmap.orange_background, R.string.zk_ch_title_UDisk_Manage, R.mipmap.udik_icon));
        // 记录查询
        this.mData.add(new ZKSettingBean(R.mipmap.dl_bg_0011, R.string.zk_record_search, R.mipmap.ic_record_inquiry_0001));
        // 广告设置
        this.mData.add(new ZKSettingBean(R.mipmap.dl_bg_0012, R.string.zk_setting_ad_title, R.mipmap.dl_ad_0002));
        // 系统信息
        this.mData.add(new ZKSettingBean(R.mipmap.pink_background, R.string.zk_ch_title_Equipment_Information, R.mipmap.devices_manage_icon));
    }

    private void initView() {
        this.title.setText(R.string.zk_system_setting_menu);// 菜单
        this.mRvContent.setLayoutManager(new GridLayoutManager(this, 2));
        this.mAdapter = new ZKSettingAdapter(getApplicationContext(), this.mData, new ZKSettingAdapter.ItemClick() {
            public void onClick(int paramInt) {
                // 记录查询
                if (paramInt != R.string.zk_record_search) {
                    // 广告设置
                    if (paramInt != R.string.zk_setting_ad_title) {
                        switch (paramInt) {
                            default:
                                return;
                            case R.string.zk_ch_title_user_manage:
                                // 员工管理
                                ZKSettingActivity.this.startActivity(new Intent(ZKSettingActivity.this, ZKEmployeeListActivity.class));
                                return;
                            case R.string.zk_ch_title_system_manage:
                                // 系统设置
                                ZKSysSettingActivity.actionStart(ZKSettingActivity.this);
                                return;
                            case R.string.zk_ch_title_push_manage:
                                // 通讯设置
                                ZKSettingActivity.this.startActivity(new Intent(ZKSettingActivity.this, ZKCommActivity.class));
                                return;
                            case R.string.zk_ch_title_data_manage:
                                // 数据管理
                                ZKSettingActivity.this.startActivity(new Intent(ZKSettingActivity.this, ZKDataManageActivity.class));
                                return;
                            case R.string.zk_ch_title_UDisk_Manage:
                                // U盘管理
                                ZKUDiskActivity.actionStart(ZKSettingActivity.this);
                                return;
                            case R.string.zk_ch_title_Equipment_Information:
                                // 系统信息
                        }
                        ZKSettingActivity.this.startActivity(new Intent(ZKSettingActivity.this, ZKSystemInfoActivity.class));
                        return;
                    }
                    ZKADSetActivity.actionStart(ZKSettingActivity.this);
                    return;
                }
                ZKAttRecordActivity.actionStart(ZKSettingActivity.this);
            }
        });
        this.mRvContent.setAdapter(this.mAdapter);
    }

    public void onBackPressed() {
        ZKSignInActivity.actionStart(this);
        finish();
        super.onBackPressed();
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        initLayout(2131427371);
        initData();
        initView();
        Intent intent = new Intent("com.zkteco.android.ACTION_UPDATE_PIC");
        intent.putExtra("picName", "123");
        sendBroadcast(intent);
    }

    @OnClick({2131296301})
    public void onViewClicked(View paramView) {
        if (paramView.getId() != 2131296301)
            return;
        onBackPressed();
    }
}
